package com.leyou.item.controller;

import com.leyou.item.dto.CategoryDTO;
import com.leyou.item.entity.Category;
import com.leyou.item.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author hcz
 * @describtion TODO
 * @date 2019-06-23 16:56
 */
@RestController
@RequestMapping("category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/of/parent")
   public ResponseEntity<List<CategoryDTO>>  queryByParentId(@RequestParam(value = "pid",defaultValue = "0")Long pid){
       List<CategoryDTO> categoryList = categoryService.queryByParentId(pid);
       return ResponseEntity.ok(categoryList);
   }
}
